package com.dy.controller;

import com.dy.service.SugarService;
import com.sugar.SugarUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @projectName: day0614
 * @package: com.dy.controller
 * @className: SugarController
 * @author: DuanYu
 * @description: TODO
 * @date: 2024/6/14 14:30
 * @version: 1.0
 */
@RestController
public class SugarController {
    @Autowired
    SugarService sugarService;

    @RequestMapping("/listMap")
    public Map showMap() {
        return SugarUtil.getMapData(sugarService.showMap());
    }

    @RequestMapping("/listXs")
    public Map showXs() {
        return SugarUtil.getBarData(sugarService.showXs());
    }

    @RequestMapping("/listXszb")
    public Map showXszb() {
        return SugarUtil.getPieData(sugarService.showXszb());
    }

    @RequestMapping("listUser")
    public String showUser() {
        List list = new ArrayList<>();
        list.add("新用户");
        list.add("老用户");
        return SugarUtil.getTablePlayData(list, sugarService.showUser());
    }

    @RequestMapping("/listTwo")
    public Map showTwo() {
        return SugarUtil.getBarData(sugarService.showTwo());
    }

    @RequestMapping("/listAge")
    public Map showAge() {
        return SugarUtil.getPieData(sugarService.showAge());
    }

    @RequestMapping("/listYys")
    public Map showYys() {
        return SugarUtil.getPieData(sugarService.showYys());
    }

    @RequestMapping("/listGender")
    public String showGender() {
        List list = new ArrayList<>();
        list.add("品牌");
        list.add("性别");
        list.add("总金额");
        return SugarUtil.getTablePlayData(list, sugarService.showGender());
    }

    @RequestMapping("/listNum")
    public Map showNum() {
        Map map = new HashMap<>();
        map.put("status", 0);
        map.put("data", sugarService.showSum());
        return map;
    }

    @RequestMapping("/listSpu")
    public String showSpu() {
        List list = new ArrayList<>();
        list.add("品牌");
        list.add("金额");
        return SugarUtil.getTablePlayData(list,sugarService.showSpu());
    }
}
